package com.wwzz;

import com.wwzz.config.UserConfiguration;
import com.wwzz.controller.*;
import com.wwzz.dao.UserRepository;
import com.wwzz.model.User;
import com.wwzz.service.UserService;
import com.wwzz.util.BeanLifeComponent;
import com.wwzz.util.UComponent;
import com.wwzz.util.UserBean;
import com.wwzz.util.UserComponent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        BeanLifeComponent beanLifeComponent = context.getBean("beanLifeComponent",BeanLifeComponent.class);
        context.destroy();
    }
    public static void main232323(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        UserControllerA userControllerA = context.getBean("userControllerA",UserControllerA.class);
        User user = userControllerA.getUser1();
        System.out.println("用户1修改之后: " + user);
        UserControllerB userControllerB = context.getBean("userControllerB",UserControllerB.class);
        User user1 = userControllerB.getUser1();
        System.out.println("用户2读取到的: " + user1);
    }
    public static void main552(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        UserController5 userController5 = context.getBean("userController5",UserController5.class);
        User user = userController5.getUser();
        System.out.println(user);
    }
    public static void main23(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        UserController controller = context.getBean("userController",UserController.class);
        User user = controller.findUserById(1);
        System.out.println(user);
    }
    public static void main33(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        UserController2 userController2 = context.getBean("userController2",UserController2.class);
        User user = userController2.findUserById(1);
        System.out.println(user);
    }
    public static void main55(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        UserController1 userController1 = context.getBean("userController1",UserController1.class);
        User user = userController1.findUserById(1);
        System.out.println(user);
    }
    public static void main2(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        UserController userController = context.getBean("userController",UserController.class);
        User user = userController.findUserById(1);
        System.out.println(user);
    }
    public static void main1(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
        UComponent uComponent = context.getBean("uComponent",UComponent.class);
        uComponent.SayHello("UComponent");


//        User user = context.getBean("u1",User.class);
//        System.out.println(user.toString());
//        User user1 = context.getBean("u2",User.class);
//        System.out.println(user1.toString());
//        User user2 = context.getBean("user",User.class);
//        System.out.println(user2.toString());



        //        UserController userController = context.getBean("userController", UserController.class);
//        userController.SayHello("Controller");
//        UserService userService = context.getBean("userService",UserService.class);
//        userService.SayHello("UserService");
//        UserRepository userRepository = context.getBean("userRepository",UserRepository.class);
//        userRepository.SayHello("UserRepository");
//        UserComponent userComponent = context.getBean("userComponent",UserComponent.class);
//        userComponent.SayHello("UserComponent");
//        UserConfiguration userConfiguration = context.getBean("userConfiguration", UserConfiguration.class);
//        userConfiguration.SayHello("UserConfiguration");
    }
}
